//
//  TargetProgressView.m
//  CoolTennisBall
//
//  Created by 谢伟康 on 15/12/15.
//  Copyright © 2015年 CoolLang. All rights reserved.
//

#import "TargetProgressView.h"
#import "ASProgressPopUpView.h"

@interface TargetProgressView ()<ASProgressPopUpViewDataSource>
@property (weak, nonatomic) IBOutlet ASProgressPopUpView *progressView;
@property (weak, nonatomic) IBOutlet UILabel *totalSwingLabel;
@property (weak, nonatomic) IBOutlet UIView *progressBgView;

@end

@implementation TargetProgressView

-(void)awakeFromNib
{
    self.progressView.font = [UIFont systemFontOfSize:12];
    self.progressView.popUpViewAnimatedColors = @[ [UIColor orangeColor]];
    self.progressView.popUpViewCornerRadius = 5;
    self.progressView.dataSource = self;
    [self.progressView showPopUpViewAnimated:YES];
    self.layer.borderWidth = 0.5;
    self.layer.borderColor = [UIColor colorWithHex:0xc9c9c9 alpha:1.0].CGColor;
    [self.progressView setProgress:0.0 animated:YES];
}

- (IBAction)clickSportTargetButton:(id)sender {
    if (self.delegate != nil && [self.delegate respondsToSelector:@selector(openSportTargetView)]) {
        [self.delegate openSportTargetView];
    }
}

- (void)configureTargetProgressViewWithWeekSwing:(NSString *)weekSwings targetSwings:(NSString *)targetSwings
{
    self.totalSwingLabel.text = weekSwings;
    [self.progressView setProgress:[weekSwings integerValue]/([targetSwings integerValue] * 1.20) animated:YES];
}

#pragma mark - ASProgressPopUpViewDataSource
- (NSString *)progressView:(ASProgressPopUpView *)progressView stringForProgress:(float)progress
{
    return [NSString stringWithFormat:@"%.f%%",progress *1.2 * 100];
}

@end
